<?php

namespace App\Http\Services;

use App\Models\SysLog;
use App\Models\Request\ReqParam;
use Illuminate\Http\Request;

class ApiLogService extends BaseService
{
    public function create(Request $request)
    {
        $reqParam = new ReqParam($request->input());
        return SysLog::create([
            'ip_addr' => $request->ip(),
            'bizcode' => $reqParam->head->bizcode,
            'funcode' => $reqParam->head->funcode,
            'userid' => $reqParam->head->userid,
            'params' => json_encode($reqParam->data, JSON_UNESCAPED_UNICODE),
            'reqtim' => date("Ymdhis")
        ]);
    }
}